package gnss

var (
	/**
	  0 - 1 s
	  1 - 2 s
	  2 - 5 s
	  3 - 10 s
	  4 - 15 s
	  5 - 30 s
	  6 - 60 s
	  7 - 120 s
	  8 - 240 s
	  9 - 300 s
	  10 - 600 s
	  11 - 900 s
	  12 - 1800 s
	  13 - 3600 s
	  14 - 7200 s
	  15 - 10800 s
	*/
	SSR_UP_INTV = [16]int{1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600, 900, 1800, 3600, 7200, 10800}
)

func SignCode2SsrSigTrackingMode(navisys byte, sigcode string) byte {
	switch navisys {
	case SYS_BD:
		/**
		  Indicator to specify the BDS signal
		  and tracking:
		   0 – B1-2 I (2I)
		   1 – B1-2 Q (2Q)
		   2 – Reserved
		   3 – B3 I (6I)
		   4 – B3 Q (6Q)
		   5 – Reserved
		   6 – B2b I (7I)
		   7 – B2b Q (7Q)
		   8 – Reserved
		   9 – B1 Data (1D)
		  10 – B1 Pilot (1P)
		  11 – Reserved
		  12 – B2a Data (5D)
		  13 – B2a Pilot (5P)
		  14 – (5X) add by taoj (2022-03-27 16:10:58)
		  15 – B1 B1A (1A)
		  16 – Reserved
		  17 – Reserved
		  18 – B3 B3A (6A)
		  >19 Reserved.
		*/
		switch sigcode {
		case "2I", "L2":
			return 0
		case "2Q":
			return 1
		case "6I", "L6":
			return 3
		case "6Q":
			return 4
		case "7I", "L7":
			return 6
		case "7Q":
			return 7
		case "1D":
			return 9
		case "1P":
			return 10
		case "5D":
			return 12
		case "5P", "L5":
			return 13
		case "5X":
			return 14
		case "1A":
			return 15
		case "6A":
			return 18
		default:
			return 255
		}
	case SYS_GPS:
		/**
		  Indicator to specify the GPS signal
		  and tracking mode:
		   0 – L1 C/A (1C)
		   1 – L1 P (AS off) (1P)
		   2 – L1 Z-tracking and similar	 (AS on) (1W)
		   3 – L1C (D) (1S)
		   4 – L1C (P) (1L)
		   5 – L2 C/A (2C)
		   6 – L2 L1(C/A)+(P2-P1)  (semi-codeless) (2D)
		   7 – L2 L2C (M) (2S)
		   8 – L2 L2C (L) (2L)
		   9 – Reserved
		   10 – L2 P (AS off) (2P)
		   11 – L2 Z-tracking and similar (AS on) (2W)
		   12 – Reserved
		   13 – Reserved
		   14 – L5 I (5I)
		   15 – L5 Q (5Q)
		  >15 Reserved.
		*/
		switch sigcode {
		case "1C", "L1":
			return 0
		case "1P":
			return 1
		case "1W":
			return 2
		case "1S":
			return 3
		case "1L":
			return 4
		case "2C":
			return 5
		case "2D":
			return 6
		case "2S":
			return 7
		case "2L":
			return 8
		case "2X":
			return 9
		case "2P":
			return 10
		case "2W", "L2":
			return 11
		case "5I", "L5":
			return 14
		case "5Q":
			return 15
		default:
			return 255
		}
	case SYS_GAL:
		/**
		  Indicator to specify the Galileo
		  signal and tracking mode:
		   0 – E1 A PRS (1A)
		   1 – E1 B I/NAV OS/CS/SoL (1B)
		   2 – E1 C no data (1C)
		   3 – E1 1X add by taoj(2024-09-13 15:09:07)
		   4 – Reserved
		   5 – E5a I F/NAV OS (5I)
		   6 – E5a Q no data (5Q)
		   7 – E5a 5X add by taoj(2024-09-13 15:09:07)
		   8 – E5b I I/NAV OS/CS/SoL (7I)
		   9 – E5b Q no data (7Q)
		   10 – E5b 7X add by taoj(2024-09-13 15:09:07)
		   11 – Reserved
		   12 – Reserved
		   13 – Reserved
		   14 – E6 A PRS (6A)
		   15 – E6 B C/NAV CS (6B)
		   16 – E6 C no data (6C)
		   17 – E6 6X add by taoj(2024-09-13 15:09:07)
		   18 – Reserved
		  >18 Reserved.
		*/
		switch sigcode {
		case "1A":
			return 0
		case "1B":
			return 1
		case "1C", "L1":
			return 2
		case "1X":
			return 3
		case "5I":
			return 5
		case "5Q", "L5":
			return 6
		case "5X":
			return 7
		case "7I":
			return 8
		case "7Q", "L7":
			return 9
		case "7X":
			return 10
		case "6A":
			return 14
		case "6B":
			return 15
		case "6C", "L6":
			return 16
		case "6X":
			return 17
		default:
			return 255
		}
	case SYS_GLO:
		/*
			Indicator to specify the GLONASS
			signal and tracking mode:
			 0 – G1 C/A (1C)
			 1 – G1 P (1P)
			 2 – G2 C/A (GLONASS M) (2C)
			 3 – G2 P (2P)
			 4 – G1a L1OCd (4A)
			 5 – G1a L1OCp (4B)
			 6 – G2a L2CSI (6A)
			 7 – G2a L2OCp (6B)
			 8 – G3 I (3I)
			 9 – G3 Q (3Q)
			>10 Reserved
		*/
		switch sigcode {
		case "1C":
			return 0
		case "1P", "L1":
			return 1
		case "2C":
			return 2
		case "2P", "L2":
			return 3
		case "4A":
			return 4
		case "4B":
			return 5
		case "6A":
			return 6
		case "6B":
			return 7
		case "3I":
			return 8
		case "3Q":
			return 9
		default:
			return 255
		}
	}
	return 255
}
